package easymall.controller;

import easymall.po.User;
import easymall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
//@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public User login(@RequestBody User user) {
        return userService.login(user);
    }

    @GetMapping("/checkUsername")
    public Boolean checkUsername(@RequestParam String username) {
        return userService.checkUsername(username);
    }

    @PostMapping("/regist")
    public int regist(@RequestBody User user) {
        return userService.regist(user);
    }

    @GetMapping("/getUser")
    public User getUser(@RequestParam Integer id) {
        return userService.getUser(id);
    }

    @GetMapping("modifyValid")
    public int modifyValid(@RequestParam Integer id) {
        return userService.modifyValid(id);
    }

    @GetMapping("getValid")
    public int getValid(@RequestParam Integer id) {
        return userService.getValid(id);
    }

    @PostMapping("remove")
    public int remove(@RequestBody User user) {
        return userService.remove(user);
    }
}
